<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>投诉信息--->详情</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <link rel="stylesheet" href="${ctxPath}/static/manage/css/x-admin.css" media="all">
    <link rel="stylesheet" href="${ctxPath}/static/manage/layui/css/layui.css" media="all">
</head>
<body>

<div class="x-body">
    <form id="complainAddForm" class="layui-form">
        <div class="layui-form-item">
            <label class="layui-form-label">投诉类型</label>
            <div class="layui-input-block">
                <select name="complaintsType" id="complaintsType" lay-filter="aihao">
                    <option value="">请选择</option>
                </select>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">投诉内容</label>
            <div class="layui-input-block">
                <input type="text" id="complaintsContent" name="complaintsContent" lay-verify="title" autocomplete="off"   placeholder="请输入要添加的内容" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-input-block">
                <button class="layui-btn layui-btn-danger" type="button" lay-submit="" lay-filter="comAdd">完成</button>
                <button class="layui-btn layui-btn-danger" lay-submit="" lay-filter="demo1" onclick="addCloseBtn()">关闭</button>
            </div>
        </div>
    </form>
</div>
</body>
<script src="${ctxPath}/static/manage/layui/layui.js" charset="utf-8"></script>
<script src="${ctxPath}/static/manage/js/x-layui.js" charset="utf-8"></script>
<script src="${ctxPath}/static/manage/js/jquery.js"></script>
<script>
    //关闭弹窗
    function addCloseBtn(){
        window.parent.location.reload();
    }

    layui.use('form',function (){
        var form = layui.form;
        var $ = layui.$;
        // 监听提交
        form.on('submit(comAdd)', function(){
            var complaintsType = $("#complaintsType option:selected").val();
            var complaintsContent = $("#complaintsContent").val();
            if( complaintsType==""){
                alert("请选择投诉类型");
                return false;
            }
            if(complaintsContent <= 0){
                alert("请输入投诉内容");
                return false;
            }

            $.ajax({
                url:'/manage/complaints/complainAdd',
                type:'post',
                data:$("#complainAddForm").serialize(),
                dataType:'text',
                success:function(result){
                    alert(result);
                    window.parent.location.reload();
                }
            });
        });

        $(function (){
            $.ajax({
                url:'/manage/complaints/complainTypeAll',
                type:'post',
                data:{},
                dataType:'json',
                success :function(res){
                    if (res.length > 0) {
                        for ( var i = 0; i < res.length; i++) {
                            $("#complaintsType").append("<option value='"+res[i].id+"'>"+ res[i].name+ "</option>");
                        }
                    }
                    form.render("select");//下拉框渲染
                }
            });
        })
    })



</script>
</html>